package cc.rengu.igas.channel.esb.biz.service.impl;

import cc.rengu.igas.channel.esb.common.constant.EsbServiceConstant;
import cc.rengu.igas.channel.esb.common.enums.RespCodeEnum;
import cc.rengu.igas.channel.esb.facade.UnionDataService;
import cc.rengu.igas.channel.esb.facade.request.*;
import cc.rengu.igas.channel.esb.facade.response.*;
import cc.rengu.igas.channel.esb.facade.result.Result;
import cc.rengu.oltp.service.model.BizException;
import cc.rengu.oltp.service.model.DubboResult;
import cc.rengu.oltp.service.realize.DubboService;
import cc.rengu.oltp.service.realize.impl.DubboServiceImpl;
import cc.rengu.utility.log.RgLog;
import cc.rengu.utility.log.RgLogger;

import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;

/**
 * Created by wangcheng
 * 银数贷记卡相关交易实现类
 */
public class UnionDataServiceImpl implements UnionDataService {
    private final RgLogger rglog = RgLog.getLogger(this.getClass().getName());

    @Override
    public Result<UpdcConsumeResponse> updcConsume(UpdcConsumeRequest updcConsumeRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UpdcConsumeResponse> result = new Result<>();
        UpdcConsumeResponse updcConsumeResponse = new UpdcConsumeResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(updcConsumeRequest, EsbServiceConstant.UPDC_CONSUME_SERVICE, UpdcConsumeResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UpdcConsumeResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("银数消费失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                updcConsumeResponse.setRespCode(((BizException) e).getCode());
                updcConsumeResponse.setRespDesc(e.getMessage());
            } else {
                updcConsumeResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                updcConsumeResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<UpdcConsumeResvalResponse> updcConsumeRevsal(UpdcConsumeResvalRequest updcConsumeResvalRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UpdcConsumeResvalResponse> result = new Result<>();
        UpdcConsumeResvalResponse updcConsumeResvalResponse = new UpdcConsumeResvalResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(updcConsumeResvalRequest, EsbServiceConstant.UPDC_CONSUME_REVSAL_SERVICE, UpdcConsumeResvalResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UpdcConsumeResvalResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("银数消费冲正失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                updcConsumeResvalResponse.setRespCode(((BizException) e).getCode());
                updcConsumeResvalResponse.setRespDesc(e.getMessage());
            } else {
                updcConsumeResvalResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                updcConsumeResvalResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<UpdcConsumeCancelResponse> updcConsumeCancel(UpdcConsumeCancelRequest updcConsumeCancelRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UpdcConsumeCancelResponse> result = new Result<>();
        UpdcConsumeCancelResponse updcConsumeCancelResponse = new UpdcConsumeCancelResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(updcConsumeCancelRequest, EsbServiceConstant.UPDC_CONSUME_CANCEL_SERVICE, UpdcConsumeCancelResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UpdcConsumeCancelResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("银数消费撤销失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                updcConsumeCancelResponse.setRespCode(((BizException) e).getCode());
                updcConsumeCancelResponse.setRespDesc(e.getMessage());
            } else {
                updcConsumeCancelResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                updcConsumeCancelResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<UpdcConsumeCancelResvalResponse> updcConsumeCancelRevsal(UpdcConsumeCancelResvalRequest updcConsumeCancelResvalRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UpdcConsumeCancelResvalResponse> result = new Result<>();
        UpdcConsumeCancelResvalResponse updcConsumeCancelResvalResponse = new UpdcConsumeCancelResvalResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(updcConsumeCancelResvalRequest, EsbServiceConstant.UPDC_CONSUME_CANCEL_REVSAL_SERVICE, UpdcConsumeCancelResvalResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UpdcConsumeCancelResvalResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("银数消费撤销冲正失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                updcConsumeCancelResvalResponse.setRespCode(((BizException) e).getCode());
                updcConsumeCancelResvalResponse.setRespDesc(e.getMessage());
            } else {
                updcConsumeCancelResvalResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                updcConsumeCancelResvalResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<UpdcConsumeRefundResponse> updcConsumeRefund(UpdcConsumeRefundRequest updcConsumeRefundRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UpdcConsumeRefundResponse> result = new Result<>();
        UpdcConsumeRefundResponse updcConsumeRefundResponse = new UpdcConsumeRefundResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(updcConsumeRefundRequest, EsbServiceConstant.UPDC_CONSUME_REFUND_SERVICE, UpdcConsumeRefundResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UpdcConsumeRefundResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("银数消费退款失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                updcConsumeRefundResponse.setRespCode(((BizException) e).getCode());
                updcConsumeRefundResponse.setRespDesc(e.getMessage());
            } else {
                updcConsumeRefundResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                updcConsumeRefundResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<UpdcStageConsumeResponse> updcStageConsume(UpdcStageConsumeRequest updcStageConsumeRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UpdcStageConsumeResponse> result = new Result<>();
        UpdcStageConsumeResponse updcStageConsumeResponse = new UpdcStageConsumeResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(updcStageConsumeRequest, EsbServiceConstant.UPDC_STAGE_CONSUME_SERVICE, UpdcStageConsumeResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UpdcStageConsumeResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("银数分期消费失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                updcStageConsumeResponse.setRespCode(((BizException) e).getCode());
                updcStageConsumeResponse.setRespDesc(e.getMessage());
            } else {
                updcStageConsumeResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                updcStageConsumeResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<UpdcStageConsumeRevsalResponse> updbStageConsumeRevsal(UpdcStageConsumeRevsalRequest updcStageConsumeRevsalRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UpdcStageConsumeRevsalResponse> result = new Result<>();
        UpdcStageConsumeRevsalResponse updcStageConsumeRevsalResponse = new UpdcStageConsumeRevsalResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(updcStageConsumeRevsalRequest, EsbServiceConstant.UPDC_STAGE_CONSUME_REVSAL_SERVICE, UpdcStageConsumeRevsalResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UpdcStageConsumeRevsalResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("银数分期消费冲正失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                updcStageConsumeRevsalResponse.setRespCode(((BizException) e).getCode());
                updcStageConsumeRevsalResponse.setRespDesc(e.getMessage());
            } else {
                updcStageConsumeRevsalResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                updcStageConsumeRevsalResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<UpdcStageConsumeCancelResponse> updbStageConsumeCancel(UpdcStageConsumeCancelRequest updcStageConsumeCancelRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UpdcStageConsumeCancelResponse> result = new Result<>();
        UpdcStageConsumeCancelResponse updcStageConsumeCancelResponse = new UpdcStageConsumeCancelResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(updcStageConsumeCancelRequest, EsbServiceConstant.UPDC_STAGE_CONSUME_CANCEL_SERVICE, UpdcStageConsumeCancelResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UpdcStageConsumeCancelResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("银数分期消费撤销失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                updcStageConsumeCancelResponse.setRespCode(((BizException) e).getCode());
                updcStageConsumeCancelResponse.setRespDesc(e.getMessage());
            } else {
                updcStageConsumeCancelResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                updcStageConsumeCancelResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<UpdcStageConsumeCancelRevsalResponse> updbStageConsumeCancelRevsal(UpdcStageConsumeCancelRevsalRequest updcStageConsumeCancelRevsalRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UpdcStageConsumeCancelRevsalResponse> result = new Result<>();
        UpdcStageConsumeCancelRevsalResponse updcStageConsumeCancelRevsalResponse = new UpdcStageConsumeCancelRevsalResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(updcStageConsumeCancelRevsalRequest, EsbServiceConstant.UPDC_STAGE_CONSUME_CANCEL_REVSAL_SERVICE, UpdcStageConsumeCancelRevsalResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UpdcStageConsumeCancelRevsalResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("银数分期消费撤销冲正失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                updcStageConsumeCancelRevsalResponse.setRespCode(((BizException) e).getCode());
                updcStageConsumeCancelRevsalResponse.setRespDesc(e.getMessage());
            } else {
                updcStageConsumeCancelRevsalResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                updcStageConsumeCancelRevsalResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<UpdcStageTrialResponse> updbStageTrial(UpdcStageTrialRequest updcStageTrialRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UpdcStageTrialResponse> result = new Result<>();
        UpdcStageTrialResponse updcStageTrialResponse = new UpdcStageTrialResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(updcStageTrialRequest, EsbServiceConstant.UPDC_STAGE_TRIAL_SERVICE, UpdcStageTrialResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UpdcStageTrialResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("银数分期试算失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                updcStageTrialResponse.setRespCode(((BizException) e).getCode());
                updcStageTrialResponse.setRespDesc(e.getMessage());
            } else {
                updcStageTrialResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                updcStageTrialResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<UpdcPreAuthResponse> updcPreAuth(UpdcPreAuthRequest updcPreAuthRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UpdcPreAuthResponse> result = new Result<>();
        UpdcPreAuthResponse updcPreAuthResponse = new UpdcPreAuthResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(updcPreAuthRequest, EsbServiceConstant.UPDC_PRE_AUTH_SERVICE, UpdcPreAuthResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UpdcPreAuthResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("银数预授权失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                updcPreAuthResponse.setRespCode(((BizException) e).getCode());
                updcPreAuthResponse.setRespDesc(e.getMessage());
            } else {
                updcPreAuthResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                updcPreAuthResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<UpdcPreAuthRevsalResponse> updcPreAuthRevsal(UpdcPreAuthRevsalRequest updcPreAuthRevsalRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UpdcPreAuthRevsalResponse> result = new Result<>();
        UpdcPreAuthRevsalResponse updcPreAuthRevsalResponse = new UpdcPreAuthRevsalResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(updcPreAuthRevsalRequest, EsbServiceConstant.UPDC_PRE_AUTH_REVSAL_SERVICE, UpdcPreAuthRevsalResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UpdcPreAuthRevsalResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("银数预授权冲正失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                updcPreAuthRevsalResponse.setRespCode(((BizException) e).getCode());
                updcPreAuthRevsalResponse.setRespDesc(e.getMessage());
            } else {
                updcPreAuthRevsalResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                updcPreAuthRevsalResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<UpdcPreAuthCancelResponse> updcPreAuthCancel(UpdcPreAuthCancelRequest updcPreAuthCancelRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UpdcPreAuthCancelResponse> result = new Result<>();
        UpdcPreAuthCancelResponse updcPreAuthCancelResponse = new UpdcPreAuthCancelResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(updcPreAuthCancelRequest, EsbServiceConstant.UPDC_PRE_AUTH_CANCEL_SERVICE, UpdcPreAuthCancelResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UpdcPreAuthCancelResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("银数预授权撤销失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                updcPreAuthCancelResponse.setRespCode(((BizException) e).getCode());
                updcPreAuthCancelResponse.setRespDesc(e.getMessage());
            } else {
                updcPreAuthCancelResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                updcPreAuthCancelResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<UpdcPreAuthCancelRevsalResponse> updcPreAuthCancelRevsal(UpdcPreAuthCancelRevsalRequest updcPreAuthCancelRevsalRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UpdcPreAuthCancelRevsalResponse> result = new Result<>();
        UpdcPreAuthCancelRevsalResponse updcPreAuthCancelRevsalResponse = new UpdcPreAuthCancelRevsalResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(updcPreAuthCancelRevsalRequest, EsbServiceConstant.UPDC_PRE_AUTH_CANCEL_REVSAL_SERVICE, UpdcPreAuthCancelRevsalResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UpdcPreAuthCancelRevsalResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("银数预授权撤销冲正失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                updcPreAuthCancelRevsalResponse.setRespCode(((BizException) e).getCode());
                updcPreAuthCancelRevsalResponse.setRespDesc(e.getMessage());
            } else {
                updcPreAuthCancelRevsalResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                updcPreAuthCancelRevsalResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<UpdcPreAuthCompResponse> updcPreAuthComp(UpdcPreAuthCompRequest updcPreAuthCompRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UpdcPreAuthCompResponse> result = new Result<>();
        UpdcPreAuthCompResponse updcPreAuthCompResponse = new UpdcPreAuthCompResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(updcPreAuthCompRequest, EsbServiceConstant.UPDC_PRE_AUTH_COMP_SERVICE, UpdcPreAuthCompResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UpdcPreAuthCompResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("银数预授权完成失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                updcPreAuthCompResponse.setRespCode(((BizException) e).getCode());
                updcPreAuthCompResponse.setRespDesc(e.getMessage());
            } else {
                updcPreAuthCompResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                updcPreAuthCompResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<UpdcPreAuthCompRevsalResponse> updcPreAuthCompRevsal(UpdcPreAuthCompRevsalRequest updcPreAuthCompRevsalRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UpdcPreAuthCompRevsalResponse> result = new Result<>();
        UpdcPreAuthCompRevsalResponse updcPreAuthCompRevsalResponse = new UpdcPreAuthCompRevsalResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(updcPreAuthCompRevsalRequest, EsbServiceConstant.UPDC_PRE_AUTH_COMP_REVSAL_SERVICE, UpdcPreAuthCompRevsalResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UpdcPreAuthCompRevsalResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("银数预授权完成冲正失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                updcPreAuthCompRevsalResponse.setRespCode(((BizException) e).getCode());
                updcPreAuthCompRevsalResponse.setRespDesc(e.getMessage());
            } else {
                updcPreAuthCompRevsalResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                updcPreAuthCompRevsalResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<UpdcPreAuthCompCancelResponse> updcPreAuthCompCancel(UpdcPreAuthCompCancelRequest updcPreAuthCompCancelRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UpdcPreAuthCompCancelResponse> result = new Result<>();
        UpdcPreAuthCompCancelResponse updcPreAuthCompCancelResponse = new UpdcPreAuthCompCancelResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(updcPreAuthCompCancelRequest, EsbServiceConstant.UPDC_PRE_AUTH_COMP_CANCEL_SERVICE, UpdcPreAuthCompCancelResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UpdcPreAuthCompCancelResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("银数预授权完成撤销失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                updcPreAuthCompCancelResponse.setRespCode(((BizException) e).getCode());
                updcPreAuthCompCancelResponse.setRespDesc(e.getMessage());
            } else {
                updcPreAuthCompCancelResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                updcPreAuthCompCancelResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<UpdcPreAuthCompCancelRevsalResponse> updcPreAuthCompCancelRevsal(UpdcPreAuthCompCancelRevsalRequest updcPreAuthCompCancelRevsalRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UpdcPreAuthCompCancelRevsalResponse> result = new Result<>();
        UpdcPreAuthCompCancelRevsalResponse updcPreAuthCompCancelRevsalResponse = new UpdcPreAuthCompCancelRevsalResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(updcPreAuthCompCancelRevsalRequest, EsbServiceConstant.UPDC_PRE_AUTH_COMP_CANCEL_REVSAL_SERVICE, UpdcPreAuthCompCancelRevsalResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UpdcPreAuthCompCancelRevsalResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("银数预授权完成撤销冲正失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                updcPreAuthCompCancelRevsalResponse.setRespCode(((BizException) e).getCode());
                updcPreAuthCompCancelRevsalResponse.setRespDesc(e.getMessage());
            } else {
                updcPreAuthCompCancelRevsalResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                updcPreAuthCompCancelRevsalResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }

    @Override
    public Result<UpdcTransAuthVerifyQueryResponse> updcTransAuthVerifyQuery(UpdcTransAuthVerifyQueryRequest updcTransAuthVerifyQueryRequest) {
        DubboService dubboService = new DubboServiceImpl();
        Result<UpdcTransAuthVerifyQueryResponse> result = new Result<>();
        UpdcTransAuthVerifyQueryResponse updcTransAuthVerifyQueryResponse = new UpdcTransAuthVerifyQueryResponse();
        try {
            DubboResult dubboResult = dubboService.callAtomService(updcTransAuthVerifyQueryRequest, EsbServiceConstant.UPDC_TRANS_AUTH_VERIFY_QUERY_SERVICE, UpdcTransAuthVerifyQueryResponse.class);
            result.setSuccess(dubboResult.isSuccess());
            result.setResult((UpdcTransAuthVerifyQueryResponse) dubboResult.getResult());
        } catch (Exception e) {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            e.printStackTrace(new PrintWriter(byteArrayOutputStream, true));
            rglog.error("银数交易授权状态查询失败:<{}>", byteArrayOutputStream.toString());
            result.setSuccess(false);
            if (e instanceof BizException) {
                updcTransAuthVerifyQueryResponse.setRespCode(((BizException) e).getCode());
                updcTransAuthVerifyQueryResponse.setRespDesc(e.getMessage());
            } else {
                updcTransAuthVerifyQueryResponse.setRespCode(RespCodeEnum.SYSTEM_ERROR.getRespCode());
                updcTransAuthVerifyQueryResponse.setRespDesc(RespCodeEnum.SYSTEM_ERROR.getRespDesc());
            }
        }
        return result;
    }
}
